<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>分解单详细</title>
    <style type="text/css">
        .searchArea .fieldBox .label{width: 70px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">事业部</div>
                    <div class="field">
                        <input name="buOrgCd" id="buOrgCd" data-value="" placeholder="请选择" ltype="combobox">
                    </div>
                </div>
                 <div class="fieldBox">
                    <div class="label">合同号</div>
                    <div class="field">
                        <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                 <div class="fieldBox">
                    <div class="label">支付表号</div>
                    <div class="field">
                        <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                 <div class="fieldBox">
                    <div class="label">分解单号</div>
                    <div class="field">
                        <input name="vfNo" id="vfNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">资金编号</div>
                    <div class="field">
                        <input name="fundCd" id="fundCd" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                 <div class="fieldBox">
                    <div class="label">分解日期</div>
                    <div class="field">
                        <input ligerui="width:83" name="vfTmMin" id="vfTmMin" type="text" class="ui-datepicker" value="">
                        -
                        <input ligerui="width:83" name="vfTmMax" id="vfTmMax" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <sys:funcAuth resCd="exportDecomList">
                        <span id="exportXlsBtn" class="sq-button sq-button-round">导出</span>
                    </sys:funcAuth>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>
<script type="text/javascript">
    var grid = null, form = null;
    var callback = null;
    $(function () {
    	debugger;
    	 //事业部
		var buOrgCdSelect='select'
        var buOrgCdJSON = [];
        <c:if test="${not empty buOrgCdList}">
        buOrgCdJSON = ${buOrgCdList};
        </c:if>
        
    	
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/capital/capFundVfDtl/initList.do',
            parms:{vfTypCd:"1"},
            method: 'get',
            columns: [
                {display: '分解单号', name: 'vfNo', width: 130, align: 'left', enabledSort: false},
                {display: '支付表号', name: 'paySchNo', width: 130, align: 'left', enabledSort: false},
                {display: '资金编号', name: 'code', width: 130, align: 'left', enabledSort: false},
               /*  {display: '资金ID', name: 'fundId', minWidth: 100, align: 'left', enabledSort: false},
                {display: '支付表ID', name: 'paySchId', minWidth: 100, align: 'left', enabledSort: false}, */
                {display: '分解金额', name: 'amount', minWidth: 100, align: 'right', enabledSort: false,
                    render:function(rowdata,index,value){
                        return '&yen;'+FormatMoney(rowdata.amount/100);
                    }
                },
                {display: '到账日期', name: 'acceptDate', minWidth: 100, align: 'center', enabledSort: false,render:renderDate},
                {display: '分解时间', name: 'vfTm', minWidth: 100, align: 'center', enabledSort: false,render:renderDate},
                {display: '客户名称 ', name: 'cstNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '核销状态 ', name: 'vfStsCdNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '核销类型 ', name: 'vfTypCdNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '期次 ', name: 'payPd', minWidth: 100, align: 'left', enabledSort: false},
                {display: '核销人编号 ', name: 'vfUsrId', minWidth: 100, align: 'left', enabledSort: false},
                {display: '核销人名称 ', name: 'vfUsrNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '事业部名称 ', name: 'buOrgCd', minWidth: 100, align: 'left', enabledSort: false,
                	render: function (item) {
                        if (StringUtils.isNotEmpty(item.buOrgCd)) {
                        //便利数组中数据 返回一个新的数组
                        var buOrgCdNm	=buOrgCdJSON.filter(function(o){return o.key == item.buOrgCd});
                        return buOrgCdNm[0].value
                        }else {
                           
                        }
                    }
                },
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true
        });
        grid.setHeight(100);

        form=$("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            $("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
            form.setData({  //重置select等特殊表单
                "*Cd": " "
            });
        });

        callback = function () {
            grid.reload();
        };

        //查询参数
        function getSearchParams() {
            var form = new liger.get("searchBar");
            var data = form.getData();
            return data;
        }

        //导出
        $("#exportXlsBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            if(!$.trim(data.paySchNo)&&!$.trim(data.vfNo)&&!$.trim(data.fundCd)){
                $.ligerDialog.SQalert({content:"请输入支付表号或分解单号或资金编号后再导出数据", SQ_type: "warning",SQ_showButtons :true});
                return;
            }
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType:'json',
                url: '<%=path%>/capital/capFundVfDtl/exportDecomList.do',
                data:data,
                beforeSend:function(){
                    wait_dialog=$.ligerDialog.SQalert({content: '正在导出...',SQ_type: "waitting"});
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        window.open(msg.data);
                    }else{
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            });
        });
        
        //事业部
        $("#buOrgCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        liger.get("buOrgCd").setData(${buOrgCdList});
        
        
        
        
    });


    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

</script>

</body>
</html>
